package com.example.spring.service;


import com.example.spring.dao.UserDaoImpl;
import com.example.spring.task.User;

public class UserServiceImpl implements UserService{

    UserDaoImpl userDao=new UserDaoImpl();


    @Override
    public String login(String username, String password) {
        User user = userDao.login(username);

        if (user==null){
            return "用户不存在";
        }
        if (password==null||!password.equals(user.getPassword())){
            return "密码不正确";
        }
        return "登录成功";

    }

    @Override
    public String register(String username, String password, String newPassword) {

        User user1 = userDao.login(username);


        if (user1!=null){
            return "用户已存在";
        }

        if (password==null||!password.equals(newPassword)){
            return "密码有问题";
        }
        int i = userDao.register(username, password);
        return "注册成功";

    }
}
